Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add and pass more regression tests for PerseusItem parser #1924

Merged
merged 22 commits into from
Dec 3, 2024

Conversation

benchristel
Copy link
Member

Issue: LEMS-2582

Test plan:

yarn test

@benchristel benchristel self-assigned this Nov 27, 2024
Copy link
Contributor

github-actions bot commented Nov 27, 2024

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (31e1799) and published it to npm. You
can install it using the tag PR1924.

Example:

yarn add @khanacademy/perseus@PR1924

If you are working in Khan Academy's webapp, you can run:

./dev/tools/bump_perseus_version.sh -t PR1924

Copy link
Contributor

github-actions bot commented Nov 27, 2024

Size Change: +501 B (+0.04%)

Total Size: 1.29 MB

Filename Size Change
packages/perseus/dist/es/index.js 424 kB +501 B (+0.12%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 39 kB
packages/keypad-context/dist/es/index.js 760 B
packages/kmath/dist/es/index.js 4.27 kB
packages/math-input/dist/es/index.js 77.9 kB
packages/math-input/dist/es/strings.js 1.79 kB
packages/perseus-core/dist/es/index.js 1.48 kB
packages/perseus-editor/dist/es/index.js 697 kB
packages/perseus-linter/dist/es/index.js 22.2 kB
packages/perseus/dist/es/strings.js 3.7 kB
packages/pure-markdown/dist/es/index.js 3.66 kB
packages/simple-markdown/dist/es/index.js 12.5 kB

compressed-size-action

@benchristel benchristel marked this pull request as ready for review December 2, 2024 20:47
@khan-actions-bot khan-actions-bot requested a review from a team December 2, 2024 20:47
@khan-actions-bot
Copy link
Contributor

khan-actions-bot commented Dec 2, 2024

Gerald

Required Reviewers
  • @Khan/perseus for changes to .changeset/tiny-feet-give.md, packages/perseus/src/perseus-types.ts, packages/perseus/src/__tests__/renderer.test.tsx, packages/perseus/src/widgets/interactive-graph.tsx, packages/perseus/src/__tests__/__snapshots__/renderer.test.tsx.snap, packages/perseus/src/util/parse-perseus-json/README.md, packages/perseus/src/widgets/deprecated-standin/deprecated-standin.tsx, packages/perseus/src/widgets/interactive-graphs/mafs-graph.tsx, packages/perseus/src/widgets/interactive-graphs/stateful-mafs-graph.tsx, packages/perseus/src/widgets/numeric-input/numeric-input.tsx, packages/perseus/src/widgets/numeric-input/score-numeric-input.test.ts, packages/perseus/src/widgets/numeric-input/score-numeric-input.ts, packages/perseus/src/util/parse-perseus-json/perseus-parsers/definition-widget.ts, packages/perseus/src/util/parse-perseus-json/perseus-parsers/input-number-widget.ts, packages/perseus/src/util/parse-perseus-json/perseus-parsers/interactive-graph-widget.ts, packages/perseus/src/util/parse-perseus-json/perseus-parsers/number-line-widget.ts, packages/perseus/src/util/parse-perseus-json/perseus-parsers/numeric-input-widget.ts, packages/perseus/src/util/parse-perseus-json/perseus-parsers/orderer-widget.ts, packages/perseus/src/util/parse-perseus-json/perseus-parsers/passage-widget.ts, packages/perseus/src/util/parse-perseus-json/perseus-parsers/plotter-widget.ts, packages/perseus/src/util/parse-perseus-json/perseus-parsers/widgets-map.test.ts, packages/perseus/src/util/parse-perseus-json/perseus-parsers/widgets-map.ts, packages/perseus/src/widgets/interactive-graphs/reducer/initialize-graph-state.test.ts, packages/perseus/src/util/parse-perseus-json/regression-tests/__snapshots__/parse-perseus-json-snapshot.test.ts.snap, packages/perseus/src/util/parse-perseus-json/regression-tests/data/definition-missing-static.json, packages/perseus/src/util/parse-perseus-json/regression-tests/data/input-number-with-boolean-value.json, packages/perseus/src/util/parse-perseus-json/regression-tests/data/interactive-graph-missing-graph.json, packages/perseus/src/util/parse-perseus-json/regression-tests/data/interactive-graph-missing-gridStep.json, packages/perseus/src/util/parse-perseus-json/regression-tests/data/interactive-graph-missing-labels.json, packages/perseus/src/util/parse-perseus-json/regression-tests/data/number-line-missing-snapDivisions.json, packages/perseus/src/util/parse-perseus-json/regression-tests/data/numeric-input-answer-without-value.json, packages/perseus/src/util/parse-perseus-json/regression-tests/data/numeric-input-missing-labelText.json, packages/perseus/src/util/parse-perseus-json/regression-tests/data/orderer-with-invalid-height.json, packages/perseus/src/util/parse-perseus-json/regression-tests/data/orderer-with-undefined-options.json, packages/perseus/src/util/parse-perseus-json/regression-tests/data/plotter-with-undefined-plotDimensions.json

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

@benchristel benchristel requested a review from handeyeco December 2, 2024 23:29
Comment on lines 50 to 53
The `defaultProps` of a widget are used during content editing to initialize
the widget options. They represent our _current version_ of the initial widget
configuration that content creators should see when they add a widget to an
exercise.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's slight more complicated than this, in some cases. Our widget editors also have the concept of default props and in some cases it is they that provide the default value during editing.

Thinking about the two locations that provide defaults, it seems making "edit time" defaults originate from the widget editors instead of the widgets themselves would make that much clearer.

No action required here, but thanks for calling out this split in these docs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Input Number widget and its editor are a good example. The widget provides some defaults, but the editor provides different props as defaults. That's extremely difficult to reason out what the behaviour will be in production. 😖

image


import type {PerseusWidgetsMap} from "../../../perseus-types";
import type {
AutoCorrectWidget,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am completely confounded why we call this the AutoCorrectWidget when the widget type is sequence. No change needed, just me commenting out my confusion. :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AutoCorrectWidget should probably be called DeprecatedStandin.

Comment on lines 126 to 155
// Where the little black axis lines & labels (ticks) should render.
// Also known as the tick step. default [1, 1]
// NOTE(kevinb): perseus_data.go defines this as Array<number>
step: [number, number];
// Where the grid lines on the graph will render. default [1, 1]
// NOTE(kevinb): perseus_data.go defines this as Array<number>
gridStep?: [x: number, y: number];
// Where the graph points will lock to when they are dragged. default [0.5, 0.5]
// NOTE(kevinb): perseus_data.go defines this as Array<number>
snapStep?: [x: number, y: number];
// An optional image to use in the background
backgroundImage?: PerseusImageBackground;
/**
* The type of markings to display on the graph.
* - graph: shows the axes and the grid lines
* - grid: shows only the grid lines
* - none: shows no markings
*/
markings: "graph" | "grid" | "none";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is slightly OCD, but would you mind making all of these JSDoc-style (/** */) comments? Some are, but the ones that aren't won't surface their information at call sites in VSCode and Goland. It's a tiny thing but is handy when accessing the prop in code to see its comment.

image

@benchristel benchristel force-pushed the benc/regression-tests-2 branch from b483bf0 to 31e1799 Compare December 3, 2024 21:43
@benchristel benchristel merged commit 2d89ef8 into main Dec 3, 2024
10 checks passed
@benchristel benchristel deleted the benc/regression-tests-2 branch December 3, 2024 22:11
mark-fitzgerald pushed a commit that referenced this pull request Dec 5, 2024
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

# Releases
## @khanacademy/[email protected]

### Minor Changes

-   [#1901](#1901) [`051c50cf7`](051c50c) Thanks [@Myranae](https://github.com/Myranae)! - Introduces a validation function for the number line widget (extracted from the scoring function).


-   [#1936](#1936) [`d05272661`](d052726) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Changes the PerseusWidgetsMap to be extensible so that widgets can be registered outside of Perseus and still have full type safety.


-   [#1832](#1832) [`e3062b3c8`](e3062b3) Thanks [@mark-fitzgerald](https://github.com/mark-fitzgerald)! - [Numeric Input] - Update the UI to match Expression widget

### Patch Changes

-   [#1937](#1937) [`3cdabf1a3`](3cdabf1) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - TypeScript fixes


-   [#1948](#1948) [`e21a3a39b`](e21a3a3) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Refactor internally used object mapping utilities to use ES6 exports


-   [#1938](#1938) [`5e8d8468b`](5e8d846) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Type fixes


-   [#1942](#1942) [`1d2b4e7bf`](1d2b4e7) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Ensure that zoomed-in images retain alt text


-   [#1861](#1861) [`763a4ba38`](763a4ba) Thanks [@mark-fitzgerald](https://github.com/mark-fitzgerald)! - [Numeric Input] - Show format options as a list


-   [#1947](#1947) [`b8926e38a`](b8926e3) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Minor refactoring of ServerItemRenderer's componentDidUpdate to reduce duplication


-   [#1946](#1946) [`f35512786`](f355127) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Refactor scoring for `group` widget to follow the same pattern as all other widgets


-   [#1891](#1891) [`ef819ea95`](ef819ea) Thanks [@mark-fitzgerald](https://github.com/mark-fitzgerald)! - [Numeric Input] - Associate format options tooltip content with input field for assistive technologies


-   [#1945](#1945) [`e69ca3146`](e69ca31) Thanks [@nishasy](https://github.com/nishasy)! - Add global styles to reflect prod styling


-   [#1923](#1923) [`be8c06c75`](be8c06c) Thanks [@benchristel](https://github.com/benchristel)! - Internal: convert backgroundImage dimensions to numbers during parsing.


-   [#1934](#1934) [`129adebef`](129adeb) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Improve comments on some Perseus types


-   [#1924](#1924) [`2d89ef87d`](2d89ef8) Thanks [@benchristel](https://github.com/benchristel)! - Internal: add and pass regression tests for PerseusItem parser's handling of legacy data

## @khanacademy/[email protected]

### Patch Changes

-   [#1938](#1938) [`5e8d8468b`](5e8d846) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Type fixes


-   [#1937](#1937) [`3cdabf1a3`](3cdabf1) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Ensure links opening to style guide (Google Docs) set `rel="noreferrer"`


-   [#1946](#1946) [`f35512786`](f355127) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Remove debugging call in GraphSettings component

-   Updated dependencies \[[`3cdabf1a3`](3cdabf1), [`e21a3a39b`](e21a3a3), [`5e8d8468b`](5e8d846), [`1d2b4e7bf`](1d2b4e7), [`763a4ba38`](763a4ba), [`b8926e38a`](b8926e3), [`f35512786`](f355127), [`ef819ea95`](ef819ea), [`e69ca3146`](e69ca31), [`be8c06c75`](be8c06c), [`051c50cf7`](051c50c), [`129adebef`](129adeb), [`d05272661`](d052726), [`2d89ef87d`](2d89ef8), [`e3062b3c8`](e3062b3)]:
    -   @khanacademy/[email protected]

Author: khan-actions-bot

Reviewers: mark-fitzgerald

Required Reviewers:

Approved By: mark-fitzgerald

Checks: ⏭️  Publish npm snapshot, ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ gerald

Pull Request URL: #1944
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants